<template>
  <div>
    <el-button @click="getJSON">获取</el-button>
    <el-button @click="add">添加</el-button>
  </div>
  {{ data }}
</template>

<script lang="ts" setup>
import { ref } from "vue";
import axios from "axios";
import { getToken } from '@/utils/common'
import request from '@/assets/request'

const data = ref();
const getJSON = () => {
  axios({
    url: "https://s-sh-17-dplayercdn.oss.dogecdn.com/1678963.json"
  }).then(res => {
    data.value = res.data.data;
  });
}

const add = () => {
  for (let i = 0; i < data.value.length; i++) {
    let item = data.value[i];
    let param = {
      id: "1654215205313789954",
      text: item[4],
      time: item[0],
      type: item[1],
      color: item[2],
      token: getToken()
    };

    console.log(param)
    request.post("/bullet/v3/", param).then(res => {

    });
  }
}


</script>

<style>
</style>